package com.ts.test.barcode;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		Intent intent = new Intent("com.google.zxing.client.android.SCAN");
		// intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
		startActivityForResult(intent, 0);

	}

	@Override
	// public void onActivityResult(int requestCode, int resultCode, Intent
	// data) {
	// super.onActivityResult(requestCode, resultCode, data);
	// switch (requestCode) {
	// case data.REQUEST_CODE: {
	// if (resultCode != RESULT_CANCELED) {
	// IntentResult scanResult = data.parseActivityResult(
	// requestCode, resultCode, data);
	// if (scanResult != null) {
	// String upc = scanResult.getContents();
	//
	// // put whatever you want to do with the code here
	//
	// //Intent iResult new Intent
	// }
	// }
	// break;
	// }
	// }
	// }
	public void onActivityResult(int requestCode, int resultCode, Intent intent) {
		if (requestCode == 0) {
			if (resultCode == RESULT_OK) {
				String contents = intent.getStringExtra("SCAN_RESULT");
				//String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
				TextView stResult = new TextView(this);
				stResult = (TextView) findViewById(R.id.stResult);
				stResult.setText(contents);
				//Intent iResult = new Intent();
				//startActivity(iResult);
				//finish();
				
				intent = null;
				Intent iResult = new Intent();
				startActivity(iResult);
				finish();
			} else if (resultCode == RESULT_CANCELED) {
				// Handle cancel
			}
		}
	}
}
